#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64=long long;
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
void solve()
{
    int n;
    cin >> n;
    stack<i64> a;
    for(int i = 0; i < n; i++)
    {
    	int m;
    	cin >> m;
    	if(a.empty() || a.top() != m)
    	{
    		a.push(m);
    	}
    	else
    	{
    		i64 t = m;
    		while(!a.empty() && t == a.top())
    		{
    			a.pop();
    			t++;
    		}
    		a.push(t);
    	}
    }
    cout << a.size();
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
